package com.scuola;

import java.sql.Connection;
import java.sql.DriverManager;

public class Database {
	
	public Database() {}
	
	public static Connection getDbConnect(){
		ConfigFile conf = new ConfigFile();
		Connection conn = dbConnect("jdbc:mysql://"+conf.getParam("MysqlDbIp")+":3306/"+conf.getParam("dbname"), conf.getParam("username"), conf.getParam("password"));
		return conn;
	}
	
	public static Connection dbConnect (String db_conn, String db_user, String db_pass){
		
		try{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			Connection conn = DriverManager.getConnection(db_conn, db_user, db_pass);
			return conn;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}
	}

}
